layui.use(['jquery','laydate','upload'],function () {
    var $ = layui.jquery;
    var laydate = layui.laydate;
    var upload = layui.upload;
    laydate.render({
        elem:"#birthDate",
        type:"datetime",
        tigger:"click"
    });

    //上传头像
    var uploadInst = upload.render({
        elem: "#acatarUrl",
        url: "/jurisdiction/uploadFile",
        multiple: true,
        field: "file",
        size:"2M",
        accept: "images",
        before: function (obj) {
            $('#images').show();
        },
        done: function (res, index, upload) {
            var mainImage = res.data.path;
            $("#acatarUrl").attr("src",'http://'+mainImage);
            $("#mainImage").val(mainImage);
        },
        error: function () {
            //演示失败状态，并实现重传
            var demoText = $('#demoText');
            demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
            demoText.find('.demo-reload').on('click', function () {
                uploadInst.upload();
            });
        }
    });
})